﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CMSWindowsFormsApp2
{
    public partial class CustomerForm2 : Form
    {
        private SqlConnection conn;
        private SqlDataAdapter adapter;
        private DataSet cutomerDataSet;
        private BindingSource bindingSource;

        public CustomerForm2()
        {
            InitializeComponent();
        }

        private void button6_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void CustomerForm2_Load(object sender, EventArgs e)
        {
            //con
            conn = new SqlConnection("Data Source=DESKTOP-SR1MKQK;Initial Catalog=CMSDATABASE;Integrated Security=True");
            
            adapter = new SqlDataAdapter("Select * from tblCustomer",conn);
           cutomerDataSet= new DataSet();
            SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
            adapter.Fill(cutomerDataSet, "tblCustomer");
            //get data
            //set into textbox
            bindingSource=new BindingSource();
            bindingSource.DataSource = cutomerDataSet;
            bindingSource.DataMember = "tblCustomer";

            //set data into text
            txtCarNo.DataBindings.Add("Text", bindingSource, "CarNo");
            txtName.DataBindings.Add("Text", bindingSource, "name");

            txtAddress.DataBindings.Add("Text", bindingSource, "address");

            txtMake.DataBindings.Add("Text", bindingSource, "make");

        }
    }
}
